package com.bw.mvvm_common.network;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * @author KK
 * @description:
 * @date :2021/10/13 16:01
 */
public class UploadImpl implements HttpInterface{
    Retrofit retrofit;
    @Override
    public Retrofit getRetrofit() {
        OkHttpClient.Builder okbuilder = new OkHttpClient.Builder();
        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        okbuilder.addInterceptor(interceptor);
        okbuilder.connectTimeout(30, TimeUnit.SECONDS);
        okbuilder.writeTimeout(60,TimeUnit.SECONDS);
        okbuilder.readTimeout(30,TimeUnit.SECONDS);
        Retrofit.Builder builder = new Retrofit.Builder();
        builder.client(okbuilder.build());
        builder.baseUrl(Api.baseUrl);
        builder.addCallAdapterFactory(RxJava2CallAdapterFactory.create());
        builder.addConverterFactory(GsonConverterFactory.create());
        retrofit = builder.build();
        return retrofit;
    }
}
